package com.xb.system.controller;

import com.xb.model.domain.vo.AgreementVO;
import com.xb.system.common.result.Result;
import com.xb.system.service.AgreementService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/agreement")
public class AgreementController {

    @Autowired
    private AgreementService agreementService;

    /**
     * 获取协议内容
     * @param type 协议类型 ('user' 或 'privacy')
     * @return 协议内容
     */
    @GetMapping("/{type}")
    public Result<Object> getAgreementContent(@PathVariable String type) {
        try {
            String content = agreementService.getAgreementContent(type);
            return Result.ok(new AgreementVO(content));
        } catch (Exception e) {
            return Result.fail("获取协议内容失败: " + e.getMessage());
        }
    }
}
